﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Activation;
using System.ServiceModel;
using ibba.src.norisk.Contracts;
using ibba.src.norisk.BusinessLogic;
using ibba.src.norisk.ServiceImplementation.translate;

namespace ibba.src.norisk.ServiceImplementation
{
    [AspNetCompatibilityRequirements(RequirementsMode = System.ServiceModel.Activation.AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession,
                     ConcurrencyMode = ConcurrencyMode.Multiple)]

    public class Common : ICommon
    {
        private CommonBL _commonBL;

        #region ICommon Members

        public Common()
        {
            try
            {
                _commonBL = new CommonBL();
            }
            catch (Exception ex)
            {
                global.ErrorHandler.LogAndThrowFaultException(ex);
            }
        }

        public ReferenciaProcessamento ObterUltimaDataReferencia()
        {
            ReferenciaProcessamento retorno = null;

            try
            {
                retorno = TranslateCommon.Translate(_commonBL.ObterUltimaDataReferencia());
            }
            catch (Exception ex)
            {
                global.ErrorHandler.LogAndThrowFaultException(ex);
            }

            return (retorno);
        }

        public List<Origem> ObterOrigens()
        {
            List<Origem> retorno = null;

            try
            {
                retorno = TranslateCommon.Translate(_commonBL.ObterOrigens());
            }
            catch (Exception ex)
            {
                global.ErrorHandler.LogAndThrowFaultException(ex);
            }

            return retorno;
        }

        #endregion
    }
}
